using BCW;
using Holoville.HOTween;
using Holoville.HOTween.Core;
using I2.Loc;
using UnityEngine;

public class ReputationProductReward : MonoBehaviour
{
	[SerializeField]
	private UIBasicSprite image;

	[SerializeField]
	private new UILabel name;

	[SerializeField]
	private UILabel count;

	[SerializeField]
	public GameObject leagueProduct;

	[SerializeField]
	public GameObject backgroundLeague;

	public void Set(SessionReputationReward reward)
	{
		image = image.ReplaceForCurrentPlatform();
		name.text = GetName(reward);
		if (reward.rewardCount > 0)
		{
			count.text = reward.rewardCount.ToString();
		}
		else
		{
			count.gameObject.SetActive(false);
		}
		SetTexture(reward);
		PopOn();
	}

	public static string GetName(SessionReputationReward reward)
	{
		if (reward.type == SessionReputationRewardType.Gold)
		{
			return ScriptLocalization.Get("Marathon/Coins");
		}
		if (reward.type == SessionReputationRewardType.Cash)
		{
			return ScriptLocalization.Get("Marathon/Cash");
		}
		if (reward.type == SessionReputationRewardType.Star)
		{
			return ScriptLocalization.Get("Game_Common/vip_acc_experience");
		}
		Product product = MarketController.Instance.GetProduct(reward.rewardID);
		if (product != null)
		{
			return ScriptLocalization.Get("Market/" + product.id + "_title");
		}
		return null;
	}

	public static Texture GetTexture(SessionReputationReward reward)
	{
		if (reward.type == SessionReputationRewardType.Cash)
		{
			return ReputationProductRewardWindow.instance.textureCash;
		}
		if (reward.type == SessionReputationRewardType.Gold)
		{
			return ReputationProductRewardWindow.instance.textureGold;
		}
		if (reward.type == SessionReputationRewardType.Star)
		{
			return ReputationProductRewardWindow.instance.textureStar;
		}
		return MarketController.Instance.GetProductTexture(reward.rewardID);
	}

	public void SetTexture(SessionReputationReward reward)
	{
		switch (reward.type)
		{
		case SessionReputationRewardType.Gold:
			image.LoadTextureAndAlphaMask("NGUI_Textures/", "gold");
			break;
		case SessionReputationRewardType.Cash:
			image.LoadTextureAndAlphaMask("NGUI_Textures/", "cash");
			break;
		case SessionReputationRewardType.Product:
			image.LoadTextureAndAlphaMask("AtlasShopGuns/", MarketController.Instance.GetProduct(reward.rewardID).texture);
			break;
		}
	}

	private void PopOn()
	{
		HOTween.To(base.transform, 0.2f, new TweenParms().Prop("localScale", Vector3.one * 1.05f).OnComplete((TweenDelegate.TweenCallback)delegate
		{
			HOTween.To(base.transform, 0.15f, new TweenParms().Prop("localScale", Vector3.one));
		}));
	}
}
